package ink.metoo.auto.fishpi.chatroom.command

import ink.metoo.auto.fishpi.call.ChatRoomCall
import ink.metoo.auto.fishpi.chatroom.ChatRooms
import ink.metoo.auto.fishpi.chatroom.Message
import ink.metoo.auto.fishpi.chatroom.handler.MessageTypeHandler

class ViewCommand : Command {

    override val commandText: String = "/查看"

    override fun isMatch(message: Message): Boolean {
        return super.isMatch(message) && message.isMe
    }

    override fun execute(message: Message) {
        val params = message.commandParams
        val oId = params.getOrNull(1) ?: return
        ChatRoomCall.getGoodMessageRaw(oId)?.let {
            ChatRooms.systemConsole(content = "--- 以下为查看消息 ---")
            MessageTypeHandler.analysisMessage(it, true)
            ChatRooms.systemConsole(content = "--- 以上为查看消息 ---")
        }
    }
}